function last = nonnan_last(A)
% This code returns the positions of the first and last non-nan
% observations
    if size(A , 2) > 1
        error('Must be column')
    end
    last = length(A) - find(~isnan(flip(A)), 1) + 1;
end